import re

# 匹配一个文件中所有.ts片段的url
def tsUrls(m3u8, http_top='', format='ts'):
    pattern = rf"([^\s]+\.{format}[^\s]*)"
    m3u8ts = re.findall(pattern, m3u8)
    ts_urls = [f"{http_top}{ts}" for ts in m3u8ts]
    return ts_urls
